#ifndef __TEXT_COMPARE_EVENT_HPP__
#define __TEXT_COMPARE_EVENT_HPP__

#include "base_event.hpp"

namespace run_code_event_space {

struct text_compare_event : base_event<text_compare_event>  {
    template <class U>
    ProcessStatus execute_impl(run_code_context_t<U>& context, const string& resFile);
};

template <class U>
ProcessStatus text_compare_event::execute_impl(run_code_context_t<U>& context, const string& resFile) {
    const RuncodeParams& params = context.params;
    ProcessStatus ps;
    if (resFile == "") {
        ps.result = LESS_STDFILES;
        ps.error = "less result text-compare file";
        return ps;
    }
    ps.result = compareIStream(std::stringstream(context.get_latest_status().output), std::ifstream(resFile), params.compareFlag, strtod(params.eps.c_str(),nullptr));
    return ps;
}

}

#endif /* __TEXT_COMPARE_EVENT_HPP__ */
